//Copyright (C) 2005  Neale Clark
//
//This program is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 2 of the License, or
//(at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

package tat.mvc;

import java.awt.AWTEvent;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.WindowEvent;
import java.io.File;
import java.util.ArrayList;
import java.util.List;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;
import javax.swing.ListSelectionModel;
import javax.swing.border.BevelBorder;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.filechooser.FileFilter;

import com.borland.jbcl.layout.XYConstraints;
import com.borland.jbcl.layout.XYLayout;

public class TATFrame extends JFrame {

	TATController controller;

	JPanel contentPane;
	JMenuBar jMenuBar1 = new JMenuBar();
	JMenu jMenuFile = new JMenu();
	JMenuItem jMenuFileExit = new JMenuItem();
	JMenu jMenuHelp = new JMenu();
	JMenuItem jMenuHelpAbout = new JMenuItem();
	BorderLayout borderLayout1 = new BorderLayout();
	JPanel ButtonPanel = new JPanel();
	JPanel ListPanel = new JPanel();
	JTextPane tp = new JTextPane();
	// XYLayout xYLayout1 = new XYLayout();
	JButton actorButton = new JButton();
	JButton useCaseButton = new JButton();
	JButton classButton = new JButton();
	JButton attributeButton = new JButton();

	// relation button
	JButton classRelationButton = new JButton();
	JButton ucActorRelationButton = new JButton();
	JButton relationRequirementButton = new JButton();
	JButton requirementButton = new JButton();

	JLabel statusBar = new JLabel();
	GridLayout gridLayout1 = new GridLayout();
	JPanel actorPanel = new JPanel();
	JPanel useCasePanel = new JPanel();
	JPanel classPanel = new JPanel();
	JPanel attributePanel = new JPanel();

	// Painel Relation
	JPanel relationPanel = new JPanel();
	JPanel requirementPanel = new JPanel();

	JPanel relationUCPanel = new JPanel();

	TitledBorder titledBorder1;
	Border border1;
	TitledBorder titledBorder2;
	Border border2;
	TitledBorder titledBorder3;
	Border border3;
	TitledBorder titledBorder4;

	// Border Relation
	Border border5;
	TitledBorder titledBorder5;
	Border border6;
	TitledBorder titledBorder6;

	Border border7;
	TitledBorder titledBorder7;

	BorderLayout borderLayout2 = new BorderLayout();
	BorderLayout borderLayout3 = new BorderLayout();
	BorderLayout borderLayout4 = new BorderLayout();
	BorderLayout borderLayout5 = new BorderLayout();

	// Relation Layout
	BorderLayout borderLayout6 = new BorderLayout();
	BorderLayout borderLayout7 = new BorderLayout();
	BorderLayout borderLayout8 = new BorderLayout();

	JScrollPane actorScroll = new JScrollPane();
	JScrollPane useCaseScroll = new JScrollPane();
	JScrollPane classScroll = new JScrollPane();
	JScrollPane attributeScroll = new JScrollPane();

	// Scroll pane
	JScrollPane relationScroll = new JScrollPane();
	JScrollPane requirementScroll = new JScrollPane();

	JScrollPane relationUCScroll = new JScrollPane();

	JList actorList = new JList();
	JList useCaseList = new JList();
	JList classList = new JList();
	JList attributeList = new JList();

	// List relation
	JList relationList = new JList();
	JList requirementList = new JList();
	JList relationUCList = new JList();

	JPanel actorButtons = new JPanel();
	JPanel useCaseButtons = new JPanel();
	JPanel classButtons = new JPanel();
	JPanel attributeButtons = new JPanel();

	// Panel relationButtons
	JPanel relationButtons = new JPanel();
	JPanel requirementButtons = new JPanel();

	JPanel relationUCButtons = new JPanel();

	JButton editActorButton = new JButton();
	JButton deleteActorButton = new JButton();
	JButton editUCButton = new JButton();
	JButton deleteUCButton = new JButton();
	JButton classEditButton = new JButton();
	JButton classDeleteButton = new JButton();
	JButton editAttButton = new JButton();
	JButton deleteAttButton = new JButton();

	// Buttons painel relation
	JButton editRelationButton = new JButton();
	JButton deleteRelationButton = new JButton();
	JButton editRequirementButton = new JButton();
	JButton deleteRequirementButton = new JButton();

	JButton editRelationUCButton = new JButton();
	JButton deleteRelationUCButton = new JButton();

	Border border4;
	JMenuItem loadMenuItem = new JMenuItem();
	JFileChooser fc = new JFileChooser();

	JScrollPane textScroll = new JScrollPane();
	String selectedClass;
	JMenu createMenu = new JMenu();
	JMenuItem actorMenuItem = new JMenuItem();
	JMenuItem useCaseMenuItem = new JMenuItem();
	JMenuItem classMenuItem = new JMenuItem();
	JMenuItem attMenuItem = new JMenuItem();

	// Menu
	JMenuItem relationMenuItem = new JMenuItem();
	JMenuItem requirementMenuItem = new JMenuItem();

	JButton showTextButton = new JButton();
	JButton showListRequirement = new JButton();

	JMenuItem saveTxt = new JMenuItem();
	JMenuItem saveXML = new JMenuItem();
	JMenuItem saveRequirementsReport = new JMenuItem();
	JPopupMenu conMenu = new JPopupMenu();
	JMenuItem popAtt = new JMenuItem();
	JMenuItem popClass = new JMenuItem();
	JMenuItem popUse = new JMenuItem();
	JMenuItem popActor = new JMenuItem();

	// pop Relation
	JMenuItem popRelation = new JMenuItem();
	JMenuItem popRequirement = new JMenuItem();

	JButton showXMLButton = new JButton();
	JButton sorButton = new JButton();

	ImageIcon logo;

	// Construct the frame
	public TATFrame() {
		enableEvents(AWTEvent.WINDOW_EVENT_MASK);
		try {
			jbInit();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	// Component initialization
	private void jbInit() throws Exception {
		contentPane = (JPanel) this.getContentPane();
		titledBorder1 = new TitledBorder(BorderFactory.createBevelBorder(
				BevelBorder.RAISED, Color.white, Color.white, new Color(109,
						109, 110), new Color(156, 156, 158)), "Actors");
		border1 = BorderFactory.createBevelBorder(BevelBorder.RAISED,
				Color.white, Color.white, new Color(109, 109, 110), new Color(
						156, 156, 158));
		titledBorder2 = new TitledBorder(border1, "Use Cases");
		border2 = BorderFactory.createBevelBorder(BevelBorder.RAISED,
				Color.white, Color.white, new Color(109, 109, 110), new Color(
						156, 156, 158));
		titledBorder3 = new TitledBorder(border2, "Classes");
		border3 = BorderFactory.createBevelBorder(BevelBorder.RAISED,
				Color.white, Color.white, new Color(109, 109, 110), new Color(
						156, 156, 158));

		titledBorder4 = new TitledBorder(border3, "Attributes");
		border4 = BorderFactory.createBevelBorder(BevelBorder.RAISED,
				Color.white, Color.white, new Color(109, 109, 110), new Color(
						156, 156, 158));

		titledBorder5 = new TitledBorder(border4, "Domain-Model Relations");
		border5 = BorderFactory.createBevelBorder(BevelBorder.RAISED,
				Color.white, Color.white, new Color(109, 109, 110), new Color(
						156, 156, 158));

		titledBorder6 = new TitledBorder(border5, "Requirements");
		border6 = BorderFactory.createBevelBorder(BevelBorder.RAISED,
				Color.white, Color.white, new Color(109, 109, 110), new Color(
						156, 156, 158));

		titledBorder7 = new TitledBorder(border6, "UseCase-Model Relations");
		border7 = BorderFactory.createBevelBorder(BevelBorder.RAISED,
				Color.white, Color.white, new Color(109, 109, 110), new Color(
						156, 156, 158));

		contentPane.setLayout(borderLayout1);
		this.setSize(new Dimension(800, 600));
		this.setState(Frame.NORMAL);
		this.setTitle("Text Analysis Tool 1.1");
		jMenuFile.setBackground(new Color(224, 223, 227));
		jMenuFile.setText("File");
		jMenuFileExit.setBackground(new Color(224, 223, 227));
		jMenuFileExit.setText("Exit");
		jMenuFileExit
				.addActionListener(new TATFrame_jMenuFileExit_ActionAdapter(
						this));
		jMenuHelp.setBackground(new Color(224, 223, 227));
		jMenuHelp.setText("Help");
		jMenuHelpAbout.setBackground(new Color(224, 223, 227));
		jMenuHelpAbout.setText("About");
		jMenuHelpAbout
				.addActionListener(new TATFrame_jMenuHelpAbout_ActionAdapter(
						this));
		tp.setBorder(BorderFactory.createLoweredBevelBorder());
		tp
				.setToolTipText("Highlight text and click appropriate button on left");
		tp.setEditable(false);
		tp.setSelectedTextColor(Color.yellow);
		tp.setSelectionColor(Color.blue);
		tp.addMouseListener(new TATFrame_tp_mouseAdapter(this));
		ButtonPanel.setLayout(new XYLayout());

		//ButtonPanel.setMinimumSize(new Dimension(5000,1000));
		actorButton.setPreferredSize(new Dimension(180, 25));
		actorButton.setToolTipText("Click to create Actor");
		actorButton.setText("Create Actor");
		actorButton.addActionListener(new TATFrame_actorButton_actionAdapter(
				this));

		useCaseButton.setPreferredSize(new Dimension(180, 25));
		useCaseButton.setToolTipText("Click to create Use Case");
		useCaseButton.setText("Create Use Case");
		useCaseButton
				.addActionListener(new TATFrame_useCaseButton_actionAdapter(
						this));

		classButton.setPreferredSize(new Dimension(180, 25));
		classButton.setToolTipText("Click to create Class");
		classButton.setText("Create Class");
		classButton.addActionListener(new TATFrame_classButton_actionAdapter(
				this));

		attributeButton.setPreferredSize(new Dimension(180, 25));
		attributeButton.setToolTipText("Click to create Attribute");
		attributeButton.setText("Create Attribute");
		attributeButton
				.addActionListener(new TATFrame_attributeButton_actionAdapter(
						this));

		// Botï¿½o "CriarRelaï¿½ao"

		classRelationButton.setPreferredSize(new Dimension(180, 25));
		classRelationButton.setToolTipText("Click to create Domain-Model Relation");
		classRelationButton.setText("Create Domain-Model Relation");
		classRelationButton
				.addActionListener(new TATFrame_relationButton_actionAdapter(
						this));

		ucActorRelationButton.setPreferredSize(new Dimension(180, 25));
		ucActorRelationButton.setToolTipText("Click to create UseCase-Model Relation");
		ucActorRelationButton.setText("Create UC-Model Relation");
		ucActorRelationButton
				.addActionListener(new TATFrame_ucActorRelationButton_actionAdapter(
						this));


		requirementButton.setPreferredSize(new Dimension(180, 25));
		requirementButton.setToolTipText("Click to create Requirement");
		requirementButton.setText("Create Text Requiriment");
		requirementButton
				.addActionListener(new TATFrame_requirementButton_actionAdapter(
						this));
		


		relationRequirementButton.setPreferredSize(new Dimension(180, 25));
		relationRequirementButton.setToolTipText("Click to create Relation-Requirement");
		relationRequirementButton.setText("Create Relation-Requiriment");
		relationRequirementButton
				.addActionListener(new TATFrame_relationRequirementButton_actionAdapter(
						this));

		statusBar.setBorder(border4);
		statusBar.setMaximumSize(new Dimension(51, 25));
		statusBar.setMinimumSize(new Dimension(51, 25));
		statusBar.setPreferredSize(new Dimension(51, 25));
		statusBar.setText("");

		
		
		//Dimensões 
		ButtonPanel.setPreferredSize(new Dimension(190, 174));
		ListPanel.setPreferredSize(new Dimension(400, 10));
		
		ListPanel.setLayout(gridLayout1);
		gridLayout1.setColumns(7);
		gridLayout1.setRows(7);
		gridLayout1.setVgap(8);
		actorPanel.setBorder(titledBorder1);
		actorPanel.setMinimumSize(new Dimension(289, 194));
		actorPanel.setLayout(borderLayout2);
		useCasePanel.setBorder(titledBorder2);
		useCasePanel.setMinimumSize(new Dimension(289, 194));
		useCasePanel.setLayout(borderLayout3);

		classPanel.setBorder(titledBorder3);
		classPanel.setLayout(borderLayout4);

		attributePanel.setBorder(titledBorder4);
		attributePanel.setLayout(borderLayout5);

		// Relation Painel

		relationPanel.setBorder(titledBorder5);
		relationPanel.setMinimumSize(new Dimension(289, 194));
		relationPanel.setLayout(borderLayout6);

		requirementPanel.setBorder(titledBorder6);
		requirementPanel.setLayout(borderLayout7);

		relationUCPanel.setMinimumSize(new Dimension(289, 194));
		relationUCPanel.setBorder(titledBorder7);
		relationUCPanel.setLayout(borderLayout8);

		actorScroll
				.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
		useCaseScroll
				.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
		classScroll
				.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
		attributeScroll
				.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
		// Relation Scroll
		relationScroll
				.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

		relationUCScroll
				.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

		requirementScroll
				.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

		editActorButton.setMaximumSize(new Dimension(65, 25));
		editActorButton.setMinimumSize(new Dimension(65, 25));
		editActorButton.setPreferredSize(new Dimension(65, 25));
		editActorButton.setToolTipText("Click to edit Actor");
		editActorButton.setText("Edit");
		editActorButton
				.addActionListener(new TATFrame_editActorButton_actionAdapter(
						this));
		deleteActorButton.setToolTipText("Click to delete Actor");
		deleteActorButton.setText("Delete");
		deleteActorButton
				.addActionListener(new TATFrame_deleteActorButton_actionAdapter(
						this));
		editUCButton.setMaximumSize(new Dimension(65, 25));
		editUCButton.setMinimumSize(new Dimension(65, 25));
		editUCButton.setPreferredSize(new Dimension(65, 25));
		editUCButton.setToolTipText("Click to edit Use Case");
		editUCButton.setText("Edit");
		editUCButton.addActionListener(new TATFrame_editUCButton_actionAdapter(
				this));
		deleteUCButton.setToolTipText("Click to delete Use Case");
		deleteUCButton.setText("Delete");
		deleteUCButton
				.addActionListener(new TATFrame_deleteUCButton_actionAdapter(
						this));
		classEditButton.setMaximumSize(new Dimension(65, 25));
		classEditButton.setMinimumSize(new Dimension(65, 25));
		classEditButton.setPreferredSize(new Dimension(65, 25));
		classEditButton.setToolTipText("Click to edit Class");
		classEditButton.setText("Edit");
		classEditButton
				.addActionListener(new TATFrame_classEditButton_actionAdapter(
						this));
		classDeleteButton.setToolTipText("Click to delete Class");
		classDeleteButton.setText("Delete");
		classDeleteButton
				.addActionListener(new TATFrame_classDeleteButton_actionAdapter(
						this));
		editAttButton.setMaximumSize(new Dimension(65, 25));
		editAttButton.setMinimumSize(new Dimension(65, 25));
		editAttButton.setPreferredSize(new Dimension(65, 25));
		editAttButton.setToolTipText("Click to edit Attribute");
		editAttButton.setText("Edit");
		editAttButton
				.addActionListener(new TATFrame_editAttButton_actionAdapter(
						this));
		deleteAttButton.setToolTipText("Click to delete Attribute");
		deleteAttButton.setText("Delete");
		deleteAttButton
				.addActionListener(new TATFrame_deleteAttButton_actionAdapter(
						this));

		// Config button relation
		editRelationButton.setMaximumSize(new Dimension(65, 25));
		editRelationButton.setMinimumSize(new Dimension(65, 25));
		editRelationButton.setPreferredSize(new Dimension(65, 25));
		editRelationButton.setToolTipText("Click to edit Requirement");
		editRelationButton.setText("Edit");
		editRelationButton
				.addActionListener(new TATFrame_editRelationButton_actionAdapter(
						this));
		deleteRelationButton.setToolTipText("Click to delete Requirement");
		deleteRelationButton.setText("Delete");
		deleteRelationButton
				.addActionListener(new TATFrame_deleteRelationButton_actionAdapter(
						this));

		editRequirementButton.setMaximumSize(new Dimension(65, 25));
		editRequirementButton.setMinimumSize(new Dimension(65, 25));
		editRequirementButton.setPreferredSize(new Dimension(65, 25));
		editRequirementButton.setToolTipText("Click to edit Requirement");
		editRequirementButton.setText("Edit");
		editRequirementButton
				.addActionListener(new TATFrame_editRequirementButton_actionAdapter(
						this));
		deleteRequirementButton.setToolTipText("Click to delete Requirement");
		deleteRequirementButton.setText("Delete");
		deleteRequirementButton
				.addActionListener(new TATFrame_deleteRequirementButton_actionAdapter(
						this));

		editRelationUCButton.setMaximumSize(new Dimension(65, 25));
		editRelationUCButton.setMinimumSize(new Dimension(65, 25));
		editRelationUCButton.setPreferredSize(new Dimension(65, 25));
		editRelationUCButton.setToolTipText("Click to edit Relation");
		editRelationUCButton.setText("Edit");
		editRelationUCButton
				.addActionListener(new TATFrame_editRelationButton_actionAdapter(
						this));
		deleteRelationUCButton.setToolTipText("Click to delete Relation");
		deleteRelationUCButton.setText("Delete");
		deleteRelationUCButton
				.addActionListener(new TATFrame_deleteRelationUCButton_actionAdapter(
						this));

		attributeList
				.setToolTipText("Select Attribute and click appropriate button below");
		attributeList.setVerifyInputWhenFocusTarget(true);
		attributeList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		classList
				.setToolTipText("Select Class and click appropriate button below");
		classList
				.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

		// classList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

		useCaseList
				.setToolTipText("Select Use Case and click appropriate button below");
		useCaseList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		actorList
				.setToolTipText("Select Actor and click appropriate button below");
		actorList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

		// Realiton List
		relationList
				.setToolTipText("Select Relation and click appropriate button below");
		relationList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

		requirementList
				.setToolTipText("Select Requirement  and click appropriate button below");
		requirementList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

		loadMenuItem.setBackground(new Color(224, 223, 227));
		loadMenuItem.setText("Load SOR");
		loadMenuItem.addActionListener(new TATFrame_loadMenuItem_actionAdapter(
				this));
		fc.setAcceptAllFileFilterUsed(false);
		createMenu.setBackground(new Color(224, 223, 227));
		createMenu.setText("Create");
		actorMenuItem.setBackground(new Color(224, 223, 227));
		actorMenuItem.setText("Actor");
		actorMenuItem
				.addActionListener(new TATFrame_actorMenuItem_actionAdapter(
						this));
		useCaseMenuItem.setBackground(new Color(224, 223, 227));
		useCaseMenuItem.setText("Use Case");
		useCaseMenuItem
				.addActionListener(new TATFrame_useCaseMenuItem_actionAdapter(
						this));
		classMenuItem.setBackground(new Color(224, 223, 227));
		classMenuItem.setText("Class");
		classMenuItem
				.addActionListener(new TATFrame_classMenuItem_actionAdapter(
						this));
		attMenuItem.setBackground(new Color(224, 223, 227));
		attMenuItem.setText("Attribute");
		attMenuItem.addActionListener(new TATFrame_attMenuItem_actionAdapter(
				this));

		// Relation menu obs:criar TATFrame_relationMenuItem_actionAdapter(this)
		relationMenuItem.setBackground(new Color(224, 223, 227));
		relationMenuItem.setText("Relation");
		relationMenuItem
				.addActionListener(new TATFrame_relationMenuItem_actionAdapter(
						this));

		requirementMenuItem.setBackground(new Color(224, 223, 227));
		requirementMenuItem.setText("Requirement");
		requirementMenuItem
				.addActionListener(new TATFrame_requirementMenuItem_actionAdapter(
						this));

		showTextButton.setPreferredSize(new Dimension(180, 25));
		showTextButton.setText("Show Text");
		showTextButton
				.addActionListener(new TATFrame_showTextButton_actionAdapter(
						this));

		showListRequirement.setPreferredSize(new Dimension(180, 25));
		showListRequirement.setText("Show Requirements");
		showListRequirement
		.addActionListener(new TATFrame_showListRequirement_actionAdapter(
				this));

		saveTxt.setBackground(new Color(224, 223, 227));
		saveTxt.setText("Save As Text");
		saveTxt.addActionListener(new TATFrame_saveTxt_actionAdapter(this));
		saveXML.setBackground(new Color(224, 223, 227));
		saveXML.setText("Save As XML");
		saveXML.addActionListener(new TATFrame_saveXML_actionAdapter(this));
		saveRequirementsReport.setBackground(new Color(224, 223, 227));
		saveRequirementsReport.setText("Save Requirements Report");
		saveRequirementsReport.addActionListener(new TATFrame_saveRequirementsReport_actionAdapter(this));

		popAtt.setText("Create Attribute");
		popAtt.addActionListener(new TATFrame_popAtt_actionAdapter(this));
		popClass.setText("Create Class");
		popClass.addActionListener(new TATFrame_popClass_actionAdapter(this));
		popUse.setText("Create Use Case");
		popUse.addActionListener(new TATFrame_popUse_actionAdapter(this));
		popActor.setText("Create Actor");
		popActor.addActionListener(new TATFrame_popActor_actionAdapter(this));

		// pop relation creation
		popRelation.setText("Create Relation");
		popRelation.addActionListener(new TATFrame_popRelation_actionAdapter(
				this));

		popRelation.setText("Create Requirement");
		popRelation.addActionListener(new TATFrame_popRelation_actionAdapter(
				this));

		showXMLButton.setText("Show XML");
		showXMLButton
				.addActionListener(new TATFrame_showXMLButton_actionAdapter(
						this));
		sorButton.setText("Load SOR");
		sorButton.addActionListener(new TATFrame_sorButton_actionAdapter(this));
		jMenuBar1.setBackground(new Color(224, 223, 227));
		jMenuFile.add(loadMenuItem);
		jMenuFile.addSeparator();
		jMenuFile.add(saveTxt);
		jMenuFile.add(saveXML);
		jMenuFile.add(saveRequirementsReport);
		jMenuFile.addSeparator();
		jMenuFile.add(jMenuFileExit);
		jMenuHelp.add(jMenuHelpAbout);
		jMenuBar1.add(jMenuFile);
		jMenuBar1.add(createMenu);
		jMenuBar1.add(jMenuHelp);
		this.setJMenuBar(jMenuBar1);
		contentPane.add(ListPanel, BorderLayout.EAST);
		contentPane.add(ButtonPanel, BorderLayout.WEST);
		ButtonPanel.add(actorButton, new XYConstraints(5, 53, -1, -1));
		ButtonPanel.add(useCaseButton, new XYConstraints(5, 85, -1, -1));
		ButtonPanel.add(classButton, new XYConstraints(5, 117, -1, -1));
		ButtonPanel.add(attributeButton, new XYConstraints(5, 149, -1, -1));
		// adiciona ButtonRelation ao Painel
		ButtonPanel.add(classRelationButton, new XYConstraints(5, 221, -1, -1));
		ButtonPanel.add(ucActorRelationButton, new XYConstraints(5, 253, -1, -1));

		ButtonPanel.add(relationRequirementButton, new XYConstraints(5, 340, -1, -1));
		ButtonPanel.add(requirementButton, new XYConstraints(5, 308, -1, -1));



		contentPane.add(statusBar, BorderLayout.SOUTH);
		contentPane.add(textScroll, BorderLayout.CENTER);
		textScroll.getViewport().add(tp, null);

		ButtonPanel.add(showTextButton, new XYConstraints(5, 382, -1, -1));
		ButtonPanel.add(showXMLButton, new XYConstraints(5, 418, 180, 25));

		ButtonPanel
				.add(showListRequirement, new XYConstraints(5, 450, 180, 25));

		ButtonPanel.add(sorButton, new XYConstraints(5, 536, 180, 25));
		ListPanel.add(actorPanel, null);
		ListPanel.add(useCasePanel, null);

		ListPanel.add(relationUCPanel, null);

		ListPanel.add(classPanel, null);
		ListPanel.add(attributePanel, null);

		// List Relation
		ListPanel.add(relationPanel, null);
		ListPanel.add(requirementPanel, null);

		actorPanel.add(actorScroll, BorderLayout.CENTER);
		actorScroll.getViewport().add(actorList, null);
		useCasePanel.add(useCaseScroll, BorderLayout.CENTER);
		classPanel.add(classScroll, BorderLayout.CENTER);
		attributePanel.add(attributeScroll, BorderLayout.CENTER);
		useCaseScroll.getViewport().add(useCaseList, null);
		classScroll.getViewport().add(classList, null);
		attributeScroll.getViewport().add(attributeList, null);
		actorPanel.add(actorButtons, BorderLayout.SOUTH);
		useCasePanel.add(useCaseButtons, BorderLayout.SOUTH);
		classPanel.add(classButtons, BorderLayout.SOUTH);
		attributePanel.add(attributeButtons, BorderLayout.SOUTH);

		// List Panel
		relationPanel.add(relationButtons, BorderLayout.SOUTH);
		relationPanel.add(relationScroll, BorderLayout.CENTER);
		relationScroll.getViewport().add(relationList, null);

		relationUCPanel.add(relationUCButtons, BorderLayout.SOUTH);
		relationUCPanel.add(relationUCScroll, BorderLayout.CENTER);
		relationUCScroll.getViewport().add(relationUCList, null);

		requirementPanel.add(requirementButtons, BorderLayout.SOUTH);
		requirementPanel.add(requirementScroll, BorderLayout.CENTER);
		requirementScroll.getViewport().add(requirementList, null);

		actorButtons.add(editActorButton, null);
		actorButtons.add(deleteActorButton, null);
		useCaseButtons.add(editUCButton, null);
		useCaseButtons.add(deleteUCButton, null);
		classButtons.add(classEditButton, null);
		classButtons.add(classDeleteButton, null);
		attributeButtons.add(editAttButton, null);
		attributeButtons.add(deleteAttButton, null);

		// ListButton
		relationButtons.add(deleteRelationButton, null);

		requirementButtons.add(editRequirementButton, null);
		requirementButtons.add(deleteRequirementButton, null);

		relationButtons.add(deleteRelationButton, null);
		relationUCButtons.add(deleteRelationUCButton, null);

		createMenu.add(actorMenuItem);
		createMenu.add(useCaseMenuItem);
		createMenu.add(classMenuItem);
		createMenu.add(attMenuItem);

		// Relation..
		createMenu.add(relationMenuItem);

		createMenu.add(requirementMenuItem);

		conMenu.add(popActor);
		conMenu.add(popUse);
		conMenu.add(popClass);
		conMenu.add(popAtt);

		// Relation..
		conMenu.add(popRelation);

		conMenu.add(popRequirement);

		fc.setFileFilter(new textFilter());
		controller = new TATController(this);
		actorList.setModel(controller.getActLm());
		useCaseList.setModel(controller.getUcLm());
		classList.setModel(controller.getClaLm());
		classList.addListSelectionListener(new ClassSelectionListener());
		attributeList.setModel(controller.getAttLm());

		relationUCList.setModel(controller.getUCActorRelLm());
		relationList.setModel(controller.getClassRelLm());
		requirementList.setModel(controller.getReqLm());

		// Set icon for this frame
		logo = new ImageIcon(tat.mvc.TATFrame.class.getResource("icon1.png"));
		this.setIconImage(logo.getImage());
	}

	// File | Exit action performed
	public void jMenuFileExit_actionPerformed(final ActionEvent e) {
		System.exit(0);
	}

	// Help | About action performed
	public void jMenuHelpAbout_actionPerformed(final ActionEvent e) {
		TATFrame_AboutBox dlg = new TATFrame_AboutBox(this);
		Dimension dlgSize = dlg.getPreferredSize();
		Dimension frmSize = getSize();
		Point loc = getLocation();
		dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x,
				(frmSize.height - dlgSize.height) / 2 + loc.y);
		dlg.setModal(true);
		dlg.pack();
		dlg.show();
	}

	// Overridden so we can exit when window is closed
	@Override
	protected void processWindowEvent(final WindowEvent e) {
		super.processWindowEvent(e);
		if (e.getID() == WindowEvent.WINDOW_CLOSING) {
			jMenuFileExit_actionPerformed(null);
		}
	}

	void loadMenuItem_actionPerformed(final ActionEvent e) {
		if (e.getSource() == loadMenuItem) {
			fc.setFileFilter(new textFilter());
			int returnVal = fc.showOpenDialog(this);

			if (returnVal == JFileChooser.APPROVE_OPTION) {
				File file = fc.getSelectedFile();
				controller.readFile(file);
				tp.setCaretPosition(0);
				// Clear out data from last statement

				/**
				 * Subsituido pela nova classe TatApp
				 *
				 * controller.getApp().setActors(new HashMap());
				 * controller.getApp().setClasses(new HashMap());
				 * controller.getApp().setUseCases(new HashMap());
				 * controller.getActLm().clear(); controller.getClaLm().clear();
				 * controller.getUcLm().clear();
				 */

				controller.resetApplication();
			}
		}
	}

	void actorButton_actionPerformed(final ActionEvent e) {
		createActor();
	}

	void useCaseButton_actionPerformed(final ActionEvent e) {
		createUseCase();
	}

	void classButton_actionPerformed(final ActionEvent e) {
		createClass();
	}

	void attributeButton_actionPerformed(final ActionEvent e) {
		createAttribute();
	}

	// Relation
	void relationButton_actionPerformed(final ActionEvent e) {
		createRelation();
	}

	// Relation
	void ucActorRelationButton_actionPerformed(final ActionEvent e) {
		createUcActorRelation();
	}

	// Requirement
	void requirementButton_actionPerformed(final ActionEvent e) {
		createRequirement();
	}

	//Relation-Requirement
	void relationRequirementButton_actionPerformed(final ActionEvent e) {
		createRelationRequirement();
	}

	public void setSelectedClass(final String c) {
		selectedClass = c;
	}

	// Class to listen for selection of TATClass objects and store reference

	class ClassSelectionListener implements ListSelectionListener {
		public void valueChanged(final ListSelectionEvent e) {
			if (!e.getValueIsAdjusting()) {
				JList list = (JList) e.getSource();
				selectedClass = (String) list.getSelectedValue();
				controller.displayClassAtts(selectedClass);
			}
		}
	}

	void actorMenuItem_actionPerformed(final ActionEvent e) {
		createActor();
	}

	void useCaseMenuItem_actionPerformed(final ActionEvent e) {
		createUseCase();
	}

	void classMenuItem_actionPerformed(final ActionEvent e) {
		createClass();
	}

	void attMenuItem_actionPerformed(final ActionEvent e) {
		createAttribute();
	}

	// Realtion
	void relationMenuItem_actionPerformed(final ActionEvent e) {
		createRelation();
	}

	void requirementMenuItem_actionPerformed(final ActionEvent e) {
		createRequirement();
	}

	void createActor() {
		int pos = tp.getCaretPosition();
		String text = tp.getSelectedText();
		if (text != null) {
			controller.createActor(text);
			tp.select(0, 0); // Clears selection
			tp.setCaretPosition(pos);
		} else {
			JOptionPane.showMessageDialog(this, "Please select some text!",
					"No Text Selected", JOptionPane.WARNING_MESSAGE);
		}
	}

	void createUseCase() {
		int pos = tp.getCaretPosition();
		String text = tp.getSelectedText();
		if (text != null) {
			controller.createUseCase(text);
			tp.select(0, 0); // Clears selection
			tp.setCaretPosition(pos);
		} else {
			JOptionPane.showMessageDialog(this, "Please select some text!",
					"No Text Selected", JOptionPane.WARNING_MESSAGE);
		}
	}

	void createClass() {
		int pos = tp.getCaretPosition();
		String text = tp.getSelectedText();
		if (text != null) {
			controller.createClass(text);
			tp.select(0, 0); // Clears selection
			tp.setCaretPosition(pos);
		} else {
			JOptionPane.showMessageDialog(this, "Please select some text!",
					"No Text Selected", JOptionPane.WARNING_MESSAGE);
		}
	}

	void createAttribute() {
		int pos = tp.getCaretPosition();
		String text = tp.getSelectedText();
		if (text != null) {
			controller.createAttribute((String) classList.getSelectedValue(),
					text);
			tp.select(0, 0); // Clear selection
			tp.setCaretPosition(pos);
		} else {
			JOptionPane.showMessageDialog(this, "Please select some text!",
					"No Text Selected", JOptionPane.WARNING_MESSAGE);
		}
	}

	// Relation
	void createRelation() {
		Object[] selectedValues = classList.getSelectedValues();

		if (selectedValues.length != 2) {
			JOptionPane.showMessageDialog(this,
					"Please select two classes to create a relation.",
					"Select two classes", JOptionPane.WARNING_MESSAGE);
			return;
		}

		String origin = (String) selectedValues[0];
		String destination = (String) selectedValues[1];

		System.out.println("origin = " + origin);
		System.out.println("destination = " + destination);

		Object[] originSelectionOptions = new Object[] {origin, destination};
		int originSelection = JOptionPane.showOptionDialog(this,
													   "Choose relation origin",
													   "Origin",
													   JOptionPane.DEFAULT_OPTION,
													   JOptionPane.QUESTION_MESSAGE,
													   null,
													   originSelectionOptions,
													   originSelectionOptions[0]);

		if (originSelection == 1) {
			String temp = destination;
			destination = origin;
			origin = temp;
		}

		String originMultiplicity = JOptionPane.showInputDialog(this,
														"Enter origin multiplicity:");

		String destinationMultiplicity = JOptionPane.showInputDialog(this,
														"Enter destination multiplicity:");

		Object[] relationTypes = new Object[]{"Association", "Agregation", "Composition"};
		int relationType = JOptionPane.showOptionDialog(this,
				   "Choose Relation Type?",
				   "Relation Type",
				   JOptionPane.DEFAULT_OPTION,
				   JOptionPane.QUESTION_MESSAGE,
				   null,
				   relationTypes,
				   relationTypes[0]);

		String relationTypeName = null;
		switch (relationType) {
			case 0: relationTypeName = "Association";
					break;
			case 1: relationTypeName = "Agregation";
					break;
			case 2: relationTypeName = "Composition";
		}

		Object[] navigableOptions = new Object[] {"Yes", "No"};
		int isNavigable = JOptionPane.showOptionDialog(this,
													   "Is relation navigable?",
													   "Navigable",
													   JOptionPane.DEFAULT_OPTION,
													   JOptionPane.QUESTION_MESSAGE,
													   null,
													   navigableOptions,
													   navigableOptions[0]);

		controller.createClassRelation(origin, destination, originMultiplicity, destinationMultiplicity, relationTypeName, isNavigable == 0, false);
	}

	// Relation
	void createUcActorRelation() {
		Object selectedActorObj = actorList.getSelectedValue();
		Object selectedUseCaseObj = useCaseList.getSelectedValue();

		List<String> errorList = new ArrayList<String>();

		if (selectedActorObj == null) {
			errorList.add("Please select an Actor.\n");
		}
		if (selectedUseCaseObj == null) {
			errorList.add("Please select an Use Case.\n");
		}

		if (errorList.size() > 0) {
			StringBuilder errorMessage = new StringBuilder();

			for (String m : errorList) {
				errorMessage.append(m);
			}

			JOptionPane.showMessageDialog(this,
					errorMessage.toString(),
					"Error creating Use Case Actor Relation", JOptionPane.WARNING_MESSAGE);
			return;
		}

		String actor = (String) selectedActorObj;
		String useCase = (String) selectedUseCaseObj;

		controller.createUCActorRelation(actor, useCase);
	}

	void createRequirement() {
		int pos = tp.getCaretPosition();
		String text = tp.getSelectedText();

		if (text != null) {
			controller.createRequirement(text, pos);
			tp.select(0, 0); // Clears selection
			tp.setCaretPosition(pos);
		} else {
			JOptionPane.showMessageDialog(this, "Please select some text!",
					"No Text Selected", JOptionPane.WARNING_MESSAGE);
		}
	}

	void createUcRequirement(final String relation){

		int opt=JOptionPane.showConfirmDialog(null, "Is this relation a requirement?", "Question"
				, JOptionPane.YES_NO_CANCEL_OPTION ,
				JOptionPane.INFORMATION_MESSAGE);
		if(opt==0){
			controller.createUcRequirement(relation);
		}
	}

	void createRelationRequirement(){
		Object selectedRelationObj = relationList.getSelectedValue();
		Object selectedRelationObj1 = relationUCList.getSelectedValue();

		String relation=new String();

		List<String> errorList = new ArrayList<String>();

		if ((selectedRelationObj == null)&&(selectedRelationObj1 == null)) {
			errorList.add("Please select an Relationion.\n");
		}
		else if ((selectedRelationObj != null)&&(selectedRelationObj1 == null)){
			relation=(String)selectedRelationObj;
		}
		else if ((selectedRelationObj == null)&&(selectedRelationObj1 != null)){
			relation=(String)selectedRelationObj1;
		}
		else{
			errorList.add("Please select one Relationion.\n");
		}
		
		
		
		
		if (errorList.size() > 0) {
			StringBuilder errorMessage = new StringBuilder();

			for (String m : errorList) {
				errorMessage.append(m);
			}

			JOptionPane.showMessageDialog(this,
					errorMessage.toString(),
					"Error creating Relation-Requirement", JOptionPane.WARNING_MESSAGE);
			return;
		}

		controller.createRelationRequirement(relation);

	}

	void createDomRequirement(final String relation,final String origin,final String destination){

		int opt=JOptionPane.showConfirmDialog(null, "This relation is requirement", "Question"
				, JOptionPane.YES_NO_CANCEL_OPTION ,
				JOptionPane.INFORMATION_MESSAGE);
		if(opt==0){
			System.out.println(relation);
			controller.createDomRequirement(relation);
		}
	}

	void deleteActorButton_actionPerformed(final ActionEvent e) {
		String name = (String) actorList.getSelectedValue();
		if (name != null) {
			controller.deleteActor(name);
		} else {
			JOptionPane.showMessageDialog(this, "Select Actor to delete!",
					"No Actor Selected", JOptionPane.WARNING_MESSAGE);
		}
	}

	void deleteUCButton_actionPerformed(final ActionEvent e) {
		String name = (String) useCaseList.getSelectedValue();
		if (name != null) {
			controller.deleteUseCase(name);
		} else {
			JOptionPane.showMessageDialog(this, "Select Use Case to delete!",
					"No Use Case Selected", JOptionPane.WARNING_MESSAGE);
		}
	}

	void classDeleteButton_actionPerformed(final ActionEvent e) {
		String name = (String) classList.getSelectedValue();
		if (name != null) {
			controller.deleteClass(name);
		} else {
			JOptionPane.showMessageDialog(this, "Select Class to delete!",
					"No Class Selected", JOptionPane.WARNING_MESSAGE);
		}
	}

	// Relation
	void deleteRelationButton_actionPerformed(final ActionEvent e) {
		String name = (String) relationList.getSelectedValue();
		if (name != null) {
			controller.deleteDomainModelRelation(name);
		} else {
			JOptionPane.showMessageDialog(this, "Select Relation to delete!",
					"No Relation Selected", JOptionPane.WARNING_MESSAGE);
		}
	}

	void deleteRelationUCButton_actionPerformed(final ActionEvent e) {
		String name = (String) relationUCList.getSelectedValue();
		if (name != null) {
			controller.deleteUCActorRelation(name);
		} else {
			JOptionPane.showMessageDialog(this, "Select Relation to delete!",
					"No Relation Selected", JOptionPane.WARNING_MESSAGE);
		}
	}

	void deleteAttButton_actionPerformed(final ActionEvent e) {
		String cla = (String) classList.getSelectedValue();
		String name = (String) attributeList.getSelectedValue();
		if (name != null) {
			controller.deleteAttribute(cla, name);
		} else {
			JOptionPane.showMessageDialog(this, "Select Attribute to delete!",
					"No Attribute Selected", JOptionPane.WARNING_MESSAGE);
		}
	}

	void deleteRequirementButton_actionPerformed(final ActionEvent e) {
		String name = (String) requirementList.getSelectedValue();
		if (name != null) {
			controller.deleteRequirement(name);
		} else {
			JOptionPane.showMessageDialog(this,
					"Select Requirement to delete!", "No Requirement Selected",
					JOptionPane.WARNING_MESSAGE);
		}
	}

	void editActorButton_actionPerformed(final ActionEvent e) {
		String name = (String) actorList.getSelectedValue();
		if (name != null) {
			controller.editActor(name);
		} else {
			JOptionPane.showMessageDialog(this, "Select Actor to edit!",
					"No Actor Selected", JOptionPane.WARNING_MESSAGE);

		}
	}

	// Relation
	void editRelationButton_actionPerformed(final ActionEvent e) {
		String name = (String) actorList.getSelectedValue();
		if (name != null) {
			controller.editActor(name);
		} else {
			JOptionPane.showMessageDialog(this, "Select Relation to edit!",
					"No Relation Selected", JOptionPane.WARNING_MESSAGE);

		}
	}

	void editUCButton_actionPerformed(final ActionEvent e) {
		String name = (String) useCaseList.getSelectedValue();
		if (name != null) {
			controller.editUseCase(name);
		} else {
			JOptionPane.showMessageDialog(this, "Select Use Case to edit!",
					"No Use Case Selected", JOptionPane.WARNING_MESSAGE);

		}
	}

	void classEditButton_actionPerformed(final ActionEvent e) {
		String name = (String) classList.getSelectedValue();
		if (name != null) {
			controller.editClass(name);
		} else {
			JOptionPane.showMessageDialog(this, "Select Class to edit!",
					"No Class Selected", JOptionPane.WARNING_MESSAGE);

		}
	}

	void editAttButton_actionPerformed(final ActionEvent e) {
		String name = (String) attributeList.getSelectedValue();
		String cla = (String) classList.getSelectedValue();

		if (name != null) {
			controller.editAttribute(cla, name);
		} else {
			JOptionPane.showMessageDialog(this, "Select Attribute to edit!",
					"No Attribute Selected", JOptionPane.WARNING_MESSAGE);

		}

	}

	void editRequirementButton_actionPerformed(final ActionEvent e) {
		String name = (String) requirementList.getSelectedValue();
		if (name != null) {
			controller.editRequirement(name);
		} else {
			JOptionPane.showMessageDialog(this, "Select Requirement to edit!",
					"No Requirement Selected", JOptionPane.WARNING_MESSAGE);

		}
	}

	void showTextButton_actionPerformed(final ActionEvent e) {
		controller.showText();
	}

	void showListRequirement_actionPerformed(final ActionEvent e) {
		controller.showRequirementsReport();
	}

	// Method to save a text file of model

	void saveTxt_actionPerformed(final ActionEvent e) {
		if (e.getSource() == saveTxt) {
			fc.setFileFilter(new textFilter());
			int returnVal = fc.showSaveDialog(this);
			if (returnVal == JFileChooser.APPROVE_OPTION) {
				File sf = fc.getSelectedFile();
				File nf = setTxtExt(sf);
				controller.saveTxt(nf);
			}
		}
	}

	// Method to ensure text file saved with .txt extension

	File setTxtExt(final File f) {
		String fn = f.getAbsolutePath();
		if (!fn.endsWith(".txt")) {
			fn += ".txt";
		}
		File nf = new File(fn);
		return nf;
	}

	// Method to save an XML file of Model

	void saveXML_actionPerformed(final ActionEvent e) {
		if (e.getSource() == saveXML) {
			fc.setFileFilter(new XmlFilter());
			int returnVal = fc.showSaveDialog(this);
			if (returnVal == JFileChooser.APPROVE_OPTION) {
				File sf = fc.getSelectedFile();
				File nf = setXmlExt(sf);
				controller.saveXML(nf);
			}
		}
	}

	// Method to ensure XML file saved with .xml extension

	File setXmlExt(final File f) {
		String fn = f.getAbsolutePath();
		if (!fn.endsWith(".xml")) {
			fn += ".xml";
		}
		File nf = new File(fn);
		return nf;
	}

	void saveRequirementsReport_actionPerformed(final ActionEvent e) {
		if (e.getSource() == saveRequirementsReport) {
			fc.setFileFilter(new textFilter());
			int returnVal = fc.showSaveDialog(this);
			if (returnVal == JFileChooser.APPROVE_OPTION) {
				File sf = fc.getSelectedFile();
				File nf = setTxtExt(sf);
				controller.saveRequirementsReport(nf);
			}
		}
	}

	void tp_mouseClicked(final MouseEvent e) {
		if (e.getButton() != 1) {
			int x = e.getX();
			int y = e.getY();
			conMenu.show(tp, x, y);
		}
	}

	void showXMLButton_actionPerformed(final ActionEvent e) {
		controller.showXML();
	}

	void sorButton_actionPerformed(final ActionEvent e) {
		if (e.getSource() == sorButton) {
			fc.setFileFilter(new textFilter());
			int returnVal = fc.showOpenDialog(this);

			if (returnVal == JFileChooser.APPROVE_OPTION) {
				File file = fc.getSelectedFile();
				controller.readFile(file);
				tp.setCaretPosition(0);
				// Clear out data from last statement
				/**
				 * Subsituido pela nova classe TatApp
				 * controller.getApp().setActors(new HashMap());
				 * controller.getApp().setClasses(new HashMap());
				 * controller.getApp().setUseCases(new HashMap());
				 * controller.getActLm().clear(); controller.getClaLm().clear();
				 * controller.getUcLm().clear();
				 */
				controller.resetApplication();

			}
		}

	}

}

class TATFrame_jMenuFileExit_ActionAdapter implements ActionListener {
	TATFrame adaptee;

	TATFrame_jMenuFileExit_ActionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.jMenuFileExit_actionPerformed(e);
	}
}

class TATFrame_jMenuHelpAbout_ActionAdapter implements ActionListener {
	TATFrame adaptee;

	TATFrame_jMenuHelpAbout_ActionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.jMenuHelpAbout_actionPerformed(e);
	}
}

// Class to filter files to only files with .txt extension

class textFilter extends FileFilter {
	// Default constructor
	public textFilter() {
	};

	@Override
	public boolean accept(final File f) {
		String name = f.getName();
		if (f.isDirectory()) {
			return true;
		}

		if (name.endsWith(".txt")) {
			return true;
		} else {
			return false;
		}
	}

	@Override
	public String getDescription() {
		return "Text files only (.txt)";
	}
}

// Class to filter files to only files with .xml extension

class XmlFilter extends FileFilter {
	// Default constructor
	public XmlFilter() {
	};

	@Override
	public boolean accept(final File f) {
		String name = f.getName();
		if (f.isDirectory()) {
			return true;
		}

		if (name.endsWith(".xml")) {
			return true;
		} else {
			return false;
		}
	}

	@Override
	public String getDescription() {
		return "XML files only (.xml)";
	}
}

class TATFrame_loadMenuItem_actionAdapter implements
		java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_loadMenuItem_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.loadMenuItem_actionPerformed(e);
	}
}

class TATFrame_actorButton_actionAdapter implements
		java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_actorButton_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.actorButton_actionPerformed(e);
	}
}

class TATFrame_useCaseButton_actionAdapter implements
		java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_useCaseButton_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.useCaseButton_actionPerformed(e);
	}
}

class TATFrame_classButton_actionAdapter implements
		java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_classButton_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.classButton_actionPerformed(e);
	}
}

class TATFrame_attributeButton_actionAdapter implements
		java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_attributeButton_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.attributeButton_actionPerformed(e);
	}

}

// relation
class TATFrame_relationButton_actionAdapter implements
		java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_relationButton_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.relationButton_actionPerformed(e);
	}

}

//relation
class TATFrame_ucActorRelationButton_actionAdapter implements
		java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_ucActorRelationButton_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.ucActorRelationButton_actionPerformed(e);
	}

}

// requirement do texto
class TATFrame_requirementButton_actionAdapter implements
		java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_requirementButton_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.requirementButton_actionPerformed(e);
	}

}

class TATFrame_relationRequirementButton_actionAdapter implements
		java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_relationRequirementButton_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.relationRequirementButton_actionPerformed(e);
	}

}

class TATFrame_actorMenuItem_actionAdapter implements
		java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_actorMenuItem_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.actorMenuItem_actionPerformed(e);
	}
}

class TATFrame_useCaseMenuItem_actionAdapter implements
		java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_useCaseMenuItem_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.useCaseMenuItem_actionPerformed(e);
	}
}

class TATFrame_classMenuItem_actionAdapter implements
		java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_classMenuItem_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.classMenuItem_actionPerformed(e);
	}
}

class TATFrame_attMenuItem_actionAdapter implements
		java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_attMenuItem_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.attMenuItem_actionPerformed(e);
	}
}

// Relation
class TATFrame_relationMenuItem_actionAdapter implements
		java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_relationMenuItem_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.relationMenuItem_actionPerformed(e);
	}
}

class TATFrame_requirementMenuItem_actionAdapter implements
	java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_requirementMenuItem_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.requirementMenuItem_actionPerformed(e);
	}
}

class TATFrame_deleteActorButton_actionAdapter implements
		java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_deleteActorButton_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.deleteActorButton_actionPerformed(e);
	}
}

class TATFrame_deleteUCButton_actionAdapter implements
		java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_deleteUCButton_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.deleteUCButton_actionPerformed(e);
	}
}

class TATFrame_classDeleteButton_actionAdapter implements
		java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_classDeleteButton_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.classDeleteButton_actionPerformed(e);
	}
}

class TATFrame_deleteAttButton_actionAdapter implements
		java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_deleteAttButton_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.deleteAttButton_actionPerformed(e);
	}
}

class TATFrame_deleteRelationButton_actionAdapter implements
		java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_deleteRelationButton_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.deleteRelationButton_actionPerformed(e);
	}
}

class TATFrame_deleteRelationUCButton_actionAdapter implements
		java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_deleteRelationUCButton_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.deleteRelationUCButton_actionPerformed(e);
	}
}

class TATFrame_deleteRequirementButton_actionAdapter implements
		java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_deleteRequirementButton_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.deleteRequirementButton_actionPerformed(e);
	}
}

class TATFrame_editActorButton_actionAdapter implements
		java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_editActorButton_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.editActorButton_actionPerformed(e);
	}
}

class TATFrame_editUCButton_actionAdapter implements
		java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_editUCButton_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.editUCButton_actionPerformed(e);
	}
}

class TATFrame_classEditButton_actionAdapter implements
		java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_classEditButton_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.classEditButton_actionPerformed(e);
	}
}

class TATFrame_editAttButton_actionAdapter implements
		java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_editAttButton_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.editAttButton_actionPerformed(e);
	}
}

// Relation
class TATFrame_editRelationButton_actionAdapter implements
		java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_editRelationButton_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.editRelationButton_actionPerformed(e);
	}
}


class TATFrame_editRequirementButton_actionAdapter implements
		java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_editRequirementButton_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.editRequirementButton_actionPerformed(e);
	}
}

class TATFrame_showTextButton_actionAdapter implements
		java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_showTextButton_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.showTextButton_actionPerformed(e);
	}
}

class TATFrame_showListRequirement_actionAdapter implements
	java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_showListRequirement_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.showListRequirement_actionPerformed(e);
	}
}

class TATFrame_saveTxt_actionAdapter implements java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_saveTxt_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.saveTxt_actionPerformed(e);
	}
}

class TATFrame_saveXML_actionAdapter implements java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_saveXML_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.saveXML_actionPerformed(e);
	}
}

class TATFrame_saveRequirementsReport_actionAdapter implements java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_saveRequirementsReport_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.saveRequirementsReport_actionPerformed(e);
	}
}

class TATFrame_tp_mouseAdapter extends java.awt.event.MouseAdapter {
	TATFrame adaptee;

	TATFrame_tp_mouseAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	@Override
	public void mouseClicked(final MouseEvent e) {
		adaptee.tp_mouseClicked(e);
	}
}

class TATFrame_popActor_actionAdapter implements java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_popActor_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.actorMenuItem_actionPerformed(e);
	}
}

// relation
class TATFrame_popRelation_actionAdapter implements
		java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_popRelation_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.relationMenuItem_actionPerformed(e);
	}
}

class TATFrame_popUse_actionAdapter implements java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_popUse_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.useCaseMenuItem_actionPerformed(e);
	}
}

class TATFrame_popClass_actionAdapter implements java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_popClass_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.classMenuItem_actionPerformed(e);
	}
}

class TATFrame_popAtt_actionAdapter implements java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_popAtt_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.attMenuItem_actionPerformed(e);
	}
}

class TATFrame_showXMLButton_actionAdapter implements
		java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_showXMLButton_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.showXMLButton_actionPerformed(e);
	}
}

class TATFrame_sorButton_actionAdapter implements java.awt.event.ActionListener {
	TATFrame adaptee;

	TATFrame_sorButton_actionAdapter(final TATFrame adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(final ActionEvent e) {
		adaptee.sorButton_actionPerformed(e);
	}
}
